from django.db import models


class Author(models.Model):
    userId = models.CharField(max_length=20, primary_key=True)
    name = models.CharField(max_length=30)
    email = models.EmailField()
    photo = models.URLField()
    description = models.CharField(max_length=300)
    
    
BLOG_CONTENT_MARKDOWN = 1
BLOG_CONTENT_HTML = 2


class Blog(models.Model):
    title = models.CharField(max_length=200)
    author = models.ForeignKey(Author)
    pubTime = models.TimeField()
    contentType = models.IntegerField()
    content = models.TextField()


class Comment(models.Model):
    visitorName = models.CharField(max_length=30)
    visitorEmail = models.EmailField()
    visitorUrl = models.URLField()
    commentType = models.IntegerField()
    commentContent = models.TextField()
    commentBlog = models.ForeignKey(Blog)
    refComment = models.ForeignKey('self')
    
    
class VisitRecord(models.Model):
    ip = models.IPAddressField()
    timestamp = models.TimeField()
    visitBlog = models.ForeignKey(Blog)
    
    
class BlogInfo(models.Model):
    blog = models.ForeignKey(Blog)
    blogAbstract = models.TextField()
    

